package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.StoreCatalog;
import com.nbsaas.boot.store.api.domain.request.StoreCatalogRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.store.data.entity.StoreCatalog;

/**
* 请求对象转换成实体对象
*/

public class StoreCatalogEntityConvert  implements Converter<StoreCatalog, StoreCatalogRequest> {

    @Override
    public StoreCatalog convert(StoreCatalogRequest source) {
        StoreCatalog result = new StoreCatalog();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                    StoreCatalog parent =new StoreCatalog();
                    parent.setId(source.getParent());
                    result.setParent(parent);
                    }
        return result;
    }
}

